--[[
-- Author:      feilong
-- DateTime:    2019-10-30 23:05:48
-- Description:
--
-- 

--]]



--
g = {}
g.hotfix = new("hotfix") --热更功能

--禁止出现别的全局变量
function g.DisableGlobalVar()
	local __g = _G
	setmetatable(g, {
	    __newindex = function(_, name, value)
	        rawset(__g, name, value)
	    end,
	    __index = function(_, name)
	        return rawget(__g, name)
	    end
	})
	--防止误写全局变量
	setmetatable(__g, {
	    __newindex = function(_, name, value)
	        local msg = "ERROR, please use 'global.%s = value' instead of set global variable! "
	        error(string.format(msg, name), 0)
	    end,
	})
end

function g.AddSingleObj(obj)
	g.hotfix:addObject(obj.__cmodule_name, obj)
	if not obj.class then 
		return 
	end
	local super_class = obj.super
	while super_class do
	    if super_class and super_class.__cmodule_name then
	        --父类模块也加入热更
	        g.hotfix:addObject(super.__cmodule_name, instance)   
	    end       
	    super_class = super_class.super
	end         	
end


